Skip to content

Conversation

@Koalhack
Copy link
Contributor

@cibere
Copy link
Contributor

cibere commented Mar 19, 2025

After testing your plugin, it seems to decide not to respond in the case of an error.

If this was an explicit design decision, could you please share your reasoning? If not, could you please send a notification with an error instead of ignoring it?

Lastly, unless I'm missing something, your description seems a little misleading.

Format any text (json, csv, etc.) to another and more

No matter what my clipboard contains, the only options I get are to change the case, convert between decimal and binary, join lines w/o a delimiter, and escape quotes. I don't see how these options have much to do with json or csv, they seem to just be general text "formatting" in the scope of programming.

@Koalhack
Copy link
Contributor Author

Hi @cibere,

This is indeed an explicit design decision, because in future updates I'll be adding the ability for users to create their own custom scripts and if the user encounters an error, Flow Launcher's error system makes it easier to read the exception and help the user debug their script.

And yes, the description of my plugin at this stage of development is not accurate, it will do this kind of thing in the future. I've modified the description for now, for a better description.

"Description": "Retrieve text from the clipboard and edit it using several custom scripts"

@cibere
Copy link
Contributor

cibere commented Mar 20, 2025

Hi @cibere,

This is indeed an explicit design decision, because in future updates I'll be adding the ability for users to create their own custom scripts and if the user encounters an error, Flow Launcher's error system makes it easier to read the exception and help the user debug their script.

I see. Though as far as I could tell, the errors were being ignored and not sent to flow's error system. The only sort of logs that I can find regarding it are in flow's log file itself, which just says:

11:51:03.5303-07:00 - WARN  - JsonRPCPlugin.ExecuteAsync - Empty JSON-RPC Response.

And yes, the description of my plugin at this stage of development is not accurate, it will do this kind of thing in the future. I've modified the description for now, for a better description.

thank you for editing it. Once this plugin is done, and custom script support is added, I look forward to how useful it will be :)

@Koalhack
Copy link
Contributor Author

Hi @cibere,

Thanks for your reply, I'll be updating my plugin for custom scripts soon and adding more built-in scripts.

By the way, I don't know if I've understood what errors you're referring to, are you talking about script loading errors (metas, name, etc.) and script execution errors (code, context) or are we talking about something else?

Then I'd like to manage the errors as well as possible for future users but according to the documentation my only options would be:

  • Display the error message directly in the Flow Launcher Query results. ()
  • Send a message using the Windows notification system Flow.Launcher.ShowMsg

I'm not against these solutions, but would there be a way like the error popup displayed by Flow Launcher?

I thank you in advance for your answer and for your participation in maintaining this beautiful tool that is Flow Launcher.

@cibere
Copy link
Contributor

cibere commented Mar 21, 2025

By the way, I don't know if I've understood what errors you're referring to, are you talking about script loading errors (metas, name, etc.) and script execution errors (code, context) or are we talking about something else?

I believe they are script execution errors, however I'm not sure about anything else since the plugin is suppressing them.

Then I'd like to manage the errors as well as possible for future users but according to the documentation my only options would be:

* Display the error message directly in the Flow Launcher Query results. ()

* Send a message using the Windows notification system `Flow.Launcher.ShowMsg`

I'm not against these solutions, but would there be a way like the error popup displayed by Flow Launcher?

With JSON-RPC plugins, flow will display the error message if a plugin raises/throws an error that never got handled (thus why I said that your plugin must be suppressing them). I'm not very familiar with js/ts, so perhaps @Yusyuriv can help with identifying how the errors are getting supressed.

@Koalhack
Copy link
Contributor Author

With JSON-RPC plugins, flow will display the error message if a plugin raises/throws an error that never got handled (thus why I said that your plugin must be suppressing them). I'm not very familiar with js/ts, so perhaps @Yusyuriv can help with identifying how the errors are getting supressed.

Thank you for your fast reply. Could you tell me what modification you made to one of my scripts to get an error, or is it an error without having done anything?

@Yusyuriv
Copy link
Member

Sorry, I'm not very familiar with they way JSON-RPC works, but don't you suppress all script errors here?

  run(context: ScriptExecution) {
    vm.createContext(context);
    try {
      this.vmScript.runInContext(context);
    } catch (e) {
      console.error(`Error in VM Script execution: ${e}`);
    }
  }

What if you remove this try..catch?

@Koalhack
Copy link
Contributor Author

Hi @Yusyuriv,

The try...catch() does not suppress the error, it is supposed to "catch" all errors and currently this portion of code only executes if there is an error with the context (the clipboard value) and so far it has never been triggered yet it is this try... catch() which is executed in the case of a script writing error.

try {
      let script: string = fs.readFileSync(path).toString();

      let meta = stringRange(script, metaStartTerm, metaEndTerm);
      let jsonMeta = JSON.parse(meta) as Metas;

      let scriptObject = new Script({
        script: script,
        parameters: jsonMeta,
        builtIn: true
      });

      this.scripts.push(scriptObject);
    } catch (e) {
      console.error(`Unable to load ${path}, Error: ${e}`);
    }
  }

But as I said before, it will just display the error as a print in python, but as there's no error display system in Flow Launcher (JsonRPC), I think I'll display the errors in the query results.

@cibere
Copy link
Contributor

cibere commented Mar 21, 2025

but as there's no error display system in Flow Launcher (JsonRPC)

There is, and you can see that yourself by throwing an error at the start of your program in your main file. something in your code is suppressing the errors that get raised elsewhere in your code.

I think I'll display the errors in the query results.

Alright. let me know when you are finished

@Koalhack
Copy link
Contributor Author

Hi,

I've updated my plugin for better error handling + support for user scripts.

(sorry for the delay I've been quite busy)

@cibere
Copy link
Contributor

cibere commented May 14, 2025

Thank you for the work that you've put into this plugin

@cibere cibere merged commit b3a47d2 into Flow-Launcher:plugin_api_v2 May 14, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants